package com.dhecp.project.flowable.domain;

import com.dhecp.common.utils.DateUtils;
import com.dhecp.common.utils.StringUtils;
import com.dhecp.core.constant.FlowableConstant;
import org.flowable.engine.impl.persistence.entity.HistoricActivityInstanceEntityImpl;
import java.util.List;

/**
 * @ClassName ActHistoricActivity
 * @Description TODO
 * @Author alula
 * @Date 2019-12-02 20:17
 */
public class ActHistoricActivity  extends HistoricActivityInstanceEntityImpl {
    /**
     *
     */
    private static final long serialVersionUID = 1L;

    /** 审批批注 */
    private String comment;

    /** 办理人姓名 */
    private String assigneeName;

    private List<ActAssignee> assignees;

    /** 委托人信息 */
    private String owner;
    private String ownerName;

    private String resultStatusName;

    private String endTimeFormat;

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public String getAssigneeName() {
        return assigneeName;
    }

    public void setAssigneeName(String assigneeName) {
        this.assigneeName = assigneeName;
    }

    public List<ActAssignee> getAssignees() {
        return assignees;
    }

    public void setAssignees(List<ActAssignee> assignees) {
        this.assignees = assignees;
    }

    public String getOwner() {
        return owner;
    }

    public void setOwner(String owner) {
        this.owner = owner;
    }

    public String getOwnerName() {
        return ownerName;
    }

    public void setOwnerName(String ownerName) {
        this.ownerName = ownerName;
    }

    public String getEndTimeFormat() {
        if (this.getEndTime() != null){
            return DateUtils.dateTime(this.getEndTime());
        }
        return  "";
    }

    public String getResultStatusName() {
        String result = "";
        switch (this.activityType){
            case "startEvent":
                result = "已开始";
                break;
            case "endEvent":
                result = "已结束";
                break;
            case "userTask":
                if(StringUtils.isEmpty(this.deleteReason)){
                    result = "处理中";
                }else if(FlowableConstant.PASSED_FLAG.equals(this.deleteReason)){
                    result = "已处理";
                }else if(FlowableConstant.AUTOPASSED_FLAG.equals(this.deleteReason)){
                    result = "已自动处理";
                }else if(FlowableConstant.BACKED_FLAG.equals(this.deleteReason)){
                    result = "已回退";
                }else if(FlowableConstant.REJECTED_FLAG.equals(this.deleteReason)){
                    result = "已驳回";
                }else if(FlowableConstant.ENDED_FLAG.equals(this.deleteReason)){
                    result = "已中止";
                }else if(this.deleteReason.contains(FlowableConstant.DELETE_PRE)){
                    String reason = "";
                    if(FlowableConstant.DELETE_PRE.equals(this.deleteReason)){
                        reason = "未填写";
                    }else if(this.deleteReason.length()>8){
                        reason = this.deleteReason.substring(8);
                    }
                    result = "删除撤回-原因："+reason;
                }else if(this.deleteReason.contains(FlowableConstant.CANCEL_PRE)){
                    String reason = "";
                    if(FlowableConstant.CANCEL_PRE.equals(this.deleteReason)){
                        reason = "未填写";
                    }else if(this.deleteReason.length()>9){
                        reason = this.deleteReason.substring(9);
                    }
                    result = "发起人撤回-原因："+reason;
                }else if (this.deleteReason.contains(FlowableConstant.Act_DELETE_PRE)) {
                    result = "流程撤回-原因："+"退/驳回流程时撤回";
                }else{
                    result="已删除-原因："+this.deleteReason;
                }
                break;
            default:
                result = "未处理";
                break;
        }
        return  result;
    }

    public void setResultStatusName(String resultStatusName) {
        this.resultStatusName = resultStatusName;
    }
}
